using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{

    public partial class VICC_WFEVENTS
    {
        private void EA003001(DataRow dwInput, string events = "A001010", string msg = "")
        {
            try
            {
                if (!dwInput.Table.TableName.Contains("ABPOS"))
                    return;
                DataRow dwData = null;
                msg = Helper.ConvertGB2312To8859P1(msg);
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["ORDTYPE"] = "V";
                dwData["KRS"] = dwInput["ABPAUFKRS"];
                dwData["LFD"] = dwInput["ABPAUFLFD"];
                dwData["ARTTYPE"] = dwInput["ABPWAKZ"];
                dwData["ARTICLE"] = dwInput["ABPART"];
                dwData["COLOR"] = dwInput["ABPFARBE"];
                switch (dwInput["ABPWAKZ"].ToString())
                {
                    case "T":
                        //dwData["ARTDES"] = dwInput["ARTDES"];
                        //dwData["CDES"] = dwInput["CDES"];
                        break;
                    case "F":
                        break;
                }

                dwData["P1"] = Helper.Left("99".PadRight(40), 40);
                SResult = INTEXDBC.QueryICC_WFEVENTS(dwData, 99);
                if (SResult.Tables[0].Rows.Count > 0)
                {
                    return;
                }
                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WHAT"] = Helper.Left(msg.PadRight(800), 800);
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EA001010(DataRow dwInput, string events = "A001010", string msg = "")
        {
            try
            {
                if (dwInput.Table.TableName != "ABPOS")
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["ORDTYPE"] = "V";
                dwData["KRS"] = dwInput["ABPAUFKRS"];
                dwData["LFD"] = dwInput["ABPAUFLFD"];
                dwData["ARTTYPE"] = dwInput["ABPWAKZ"];
                dwData["ARTICLE"] = dwInput["ABPART"];
                dwData["COLOR"] = dwInput["ABPFARBE"];
                switch (dwInput["ABPWAKZ"].ToString())
                {
                    case "T":
                        //dwData["ARTDES"] = dwInput["ARTDES"];
                        //dwData["CDES"] = dwInput["CDES"];
                        break;
                    case "F":
                        break;
                }

                dwData["P1"] = Helper.Left("99".PadRight(40), 40);
                SResult = INTEXDBC.QueryICC_WFEVENTS(dwData, 99);
                if (SResult.Tables[0].Rows.Count > 0)
                {
                    return;
                }
                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void EA001011(DataRow dwInput, string events = "A001011", string msg = "")
        {
            try
            {
                if (dwInput.Table.TableName != "ABPOS")
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["ORDTYPE"] = "V";
                dwData["KRS"] = dwInput["ABPAUFKRS"];
                dwData["LFD"] = dwInput["ABPAUFLFD"];
                dwData["ARTTYPE"] = dwInput["ABPWAKZ"];
                dwData["ARTICLE"] = dwInput["ABPART"];
                dwData["COLOR"] = dwInput["ABPFARBE"];
                switch (dwInput["ABPWAKZ"].ToString())
                {
                    case "T":
                        //dwData["ARTDES"] = dwInput["ARTDES"];
                        //dwData["CDES"] = dwInput["CDES"];
                        break;
                    case "F":
                        break;
                }

                dwData["P1"] = Helper.Left("99".PadRight(40), 40);
                SResult = INTEXDBC.QueryICC_WFEVENTS(dwData, 99);
                if (SResult.Tables[0].Rows.Count > 0)
                {
                    return;
                }
                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EA001013(DataRow dwInput, string events = "A001013", string msg = "")
        {
            try
            {
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["ARTICLE"] = dwInput["ITXFART"];
                dwData["COLOR"] = dwInput["ITXFCOLOR"];
                SResult = INTEXDBC.QueryICC_WFEVENTS(dwData, 3);
                if (SResult.Tables[0].Rows.Count > 0)
                {
                    return;
                }
                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["WHAT"] = Helper.Left(msg.PadRight(800), 800);
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EA001014(DataRow dwInput, string events = "A001014", string msg = "")
        {
            try
            {
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["ARTICLE"] = dwInput["WAFART"];
                dwData["COLOR"] = dwInput["WAFZUSATZ"];

                SResult = INTEXDBC.QueryICC_WFEVENTS(dwData, 3);
                if (SResult.Tables[0].Rows.Count > 0)
                {
                    return;
                }
                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["NEWUSER"] = app.User;
                    dwData["WHAT"] = Helper.Left(msg.PadRight(800), 800);
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EA001020(DataRow dwInput, string events = "A001020", string msg = "")
        {
            try
            {
                if (dwInput.Table.TableName != "ABPOS")
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["ORDTYPE"] = "V";
                dwData["KRS"] = dwInput["ABPAUFKRS"];
                dwData["LFD"] = dwInput["ABPAUFLFD"];
                dwData["ARTTYPE"] = dwInput["ABPWAKZ"];
                dwData["ARTICLE"] = dwInput["ABPART"];
                dwData["COLOR"] = dwInput["ABPFARBE"];
                switch (dwInput["ABPWAKZ"].ToString())
                {
                    case "T":
                        //dwData["ARTDES"] = dwInput["ARTDES"];
                        //dwData["CDES"] = dwInput["CDES"];
                        break;
                    case "F":
                        break;
                }

                dwData["P1"] = Helper.Left("89".PadRight(40), 40);
                SResult = INTEXDBC.QueryICC_WFEVENTS(dwData, 99);
                if (SResult.Tables[0].Rows.Count > 0)
                {
                    return;
                }
                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }

                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EA001021(DataRow dwInput, string events = "A001021", string msg = "")
        {
            try
            {
                if (dwInput.Table.TableName != "ABPOS")
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["ORDTYPE"] = "V";
                dwData["KRS"] = dwInput["ABPAUFKRS"];
                dwData["LFD"] = dwInput["ABPAUFLFD"];
                dwData["ARTTYPE"] = dwInput["ABPWAKZ"];
                dwData["ARTICLE"] = dwInput["ABPART"];
                dwData["COLOR"] = dwInput["ABPFARBE"];
                switch (dwInput["ABPWAKZ"].ToString())
                {
                    case "T":
                        //dwData["ARTDES"] = dwInput["ARTDES"];
                        //dwData["CDES"] = dwInput["CDES"];
                        break;
                    case "F":
                        break;
                }
                dwData["P1"] = Helper.Left("89".PadRight(40), 40);
                SResult = INTEXDBC.QueryICC_WFEVENTS(dwData, 99);
                if (SResult.Tables[0].Rows.Count > 0)
                {
                    return;
                }
                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EA001022(DataRow dwInput, string events = "A001022", string msg = "")
        {
            try
            {
                if (dwInput.Table.TableName != "ABPOS")
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["ORDTYPE"] = "V";
                dwData["KRS"] = dwInput["ABPAUFKRS"];
                dwData["LFD"] = dwInput["ABPAUFLFD"];
                dwData["ARTTYPE"] = dwInput["ABPWAKZ"];
                dwData["ARTICLE"] = dwInput["ABPART"];
                dwData["COLOR"] = dwInput["ABPFARBE"];
                switch (dwInput["ABPWAKZ"].ToString())
                {
                    case "T":
                        //dwData["ARTDES"] = dwInput["ARTDES"];
                        //dwData["CDES"] = dwInput["CDES"];
                        break;
                    case "F":
                        break;
                }
                dwData["P1"] = Helper.Left("89".PadRight(40), 40);
                SResult = INTEXDBC.QueryICC_WFEVENTS(dwData, 99);
                if (SResult.Tables[0].Rows.Count > 0)
                {
                    return;
                }
                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EA999001(DataRow dwInput, string events = "A001021", string msg = "", MessageInfo msgs = null)
        {
            try
            {
                if (msgs == null)
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["WFWHEN"] = System.DateTime.Now;
                string where = msgs.Where;
                int idx1 = 0, idx2 = 0;
                idx1 = where.IndexOf(@"\");
                if (idx1 > 0)
                {
                    where = msgs.Where.Substring(idx1 - 2);
                }
                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["WFSOURCE"] = Helper.Left(where.PadRight(200), 200);
                    string src = Helper.ConvertGB2312To8859P1(msgs.Details);
                    dwData["WHAT"] = Helper.Left(src.PadRight(800), 800);
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {

            }
        }

        private void EA901001(DataRow dwInput, string events = "A001021", string msg = "", MessageInfo msgs = null)
        {
            try
            {
                if (msgs == null)
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["WFWHEN"] = System.DateTime.Now;
                dwData["ORDTYPE"] = "K";
                dwData["KRS"] = dwInput["VKPAUFKRS"];
                dwData["LFD"] = dwInput["VKPAUFLFD"];
                dwData["POS"] = dwInput["VKPAUFPOS"];
                string userid = msgs.Where;

                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["WHAT"] = Helper.Left(msgs.Details.PadRight(800), 800);
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    DataRow dwWF = INTEXDBC.SaveICC_WFEVENTS(dwData);
                    FireEvent(dwWF);
                }
            }
            catch (Exception ex)
            {

            }
        }

        private void EM002001(DataRow dwInput, string events = "A001021", string msg = "", MessageInfo msgs = null)
        {
            try
            {
                if (msgs == null)
                    return;
                if (dwInput.Table.TableName != "EKKOPF")
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["WFWHEN"] = System.DateTime.Now;
                dwData["KRS"] = dwInput["EKKAUFKRS"];
                dwData["LFD"] = dwInput["EKKAUFLFD"];
                string where = msgs.Where;
                string what = msgs.What;

                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["WFSOURCE"] = Helper.Left(where.PadRight(200), 200);
                    dwData["WHAT"] = Helper.Left(what.PadRight(800), 800);
                    dwData["HOW"] = Helper.Left(msg.PadRight(20), 20);
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EM002002(DataRow dwInput, string events = "A001021", string msg = "", MessageInfo msgs = null)
        {
            try
            {
                if (msgs == null)
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["WFWHEN"] = System.DateTime.Now;
                dwData["KRS"] = dwInput["EKKAUFKRS"];
                dwData["LFD"] = dwInput["EKKAUFLFD"];
                string where = msgs.Where;
                string what = msgs.What;

                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["WFSOURCE"] = Helper.Left(where.PadRight(200), 200);
                    dwData["WHAT"] = Helper.Left(msg.PadRight(800), 800);
                    dwData["HOW"] = Helper.Left(msg.PadRight(20), 20);
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void EA901301(DataRow dwInput, string events = "A901301", string msg = "", MessageInfo msgs = null)
        {
            try
            {
                if (msgs == null)
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["WFWHEN"] = System.DateTime.Now;
                string where = msgs.Where;

                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["WHAT"] = dwInput["ABKKDAUFTNR"].ToString();
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    DataRow dwWF = INTEXDBC.SaveICC_WFEVENTS(dwData);
                    FireEvent(dwWF);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EA901101(DataRow dwInput, string events = "A901101", string msg = "", MessageInfo msgs = null)
        {
            try
            {
                if (msgs == null)
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["WFWHEN"] = System.DateTime.Now;
                dwData["KRS"] = dwInput["EKPAUFKRS"];
                dwData["LFD"] = dwInput["EKPAUFLFD"];
                dwData["POS"] = dwInput["EKPAUFPOS"];
                string where = msgs.Where;

                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["WHAT"] = Helper.Left(msg.PadRight(800), 800);
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    DataRow dwWF = INTEXDBC.SaveICC_WFEVENTS(dwData);
                    FireEvent(dwWF);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EA901102(DataRow dwInput, string events = "A901102", string msg = "", MessageInfo msgs = null)
        {
            try
            {
                if (msgs == null)
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["WFWHEN"] = System.DateTime.Now;
                dwData["KRS"] = dwInput["EKPAUFKRS"];
                dwData["LFD"] = dwInput["EKPAUFLFD"];
                dwData["POS"] = dwInput["EKPAUFPOS"];
                string where = msgs.Where;
                string liefnr = msgs.Details;
                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["WHAT"] = Helper.Left(msg.PadRight(800), 800);
                    dwData["HOW"] = Helper.Left(liefnr.PadRight(20), 20);
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    DataRow dwWF = INTEXDBC.SaveICC_WFEVENTS(dwData);
                    FireEvent(dwWF);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EM002003(DataRow dwInput, string events = "M002003", string msg = "", MessageInfo msgs = null)
        {
            try
            {
                if (msgs == null)
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["WFWHEN"] = System.DateTime.Now;
                dwData["KRS"] = dwInput["EKPAUFKRS"];
                dwData["LFD"] = dwInput["EKPAUFLFD"];
                dwData["POS"] = dwInput["EKPAUFPOS"];
                string where = msgs.Where;
                string how = msgs.What;

                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["WFSOURCE"] = Helper.Left(where.PadRight(200), 200);
                    dwData["WHAT"] = Helper.Left(msg.PadRight(800), 800);
                    dwData["HOW"] = Helper.Left(how.PadRight(20), 20);
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void EA002010(DataRow dwInput, string events = "A002010", string msg = "", MessageInfo msgs = null)
        {
            try
            {
                if (msgs == null)
                    return;
                if (dwInput.Table.TableName != "EKKOPF")
                    return;
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["WFWHEN"] = System.DateTime.Now;
                dwData["KRS"] = dwInput["EKKAUFKRS"];
                dwData["LFD"] = dwInput["EKKAUFLFD"];
                string applier = dwInput["EKKNEUB"].ToString();
                DataRow dwEvents = null;
                var qHander = from DataRow row in this.TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             && row["WFUSER"].ToString().Trim() == applier.Trim()
                             select row;
                foreach (DataRow row in qUsers)
                {
                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["WHAT"] = dwEvents["WFEDES"];
                    dwData["NEWUSER"] = app.User;
                    dwData["NEWTIME"] = DateTime.Now.ToLocalTime().ToString();
                    INTEXDBC.SaveICC_WFEVENTS(dwData);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

    }
}
